package com.yao.springcloud.listener;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchService;
import java.util.Set;

import org.springframework.boot.devtools.filewatch.ChangedFiles;
import org.springframework.boot.devtools.filewatch.FileChangeListener;

public class FileChange implements FileChangeListener{

	@Override
	public void onChange(Set<ChangedFiles> changeSet) {
		System.out.println(changeSet+"asd");
		System.out.println("=-文件变动========");
	
		try {
			Path path = Paths.get(".");
			final WatchService watchService = path.getFileSystem().newWatchService();
			path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
			System.out.println("Report any file changed within next 1 minutes...");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
